package com.bsh.erp.pro.business.action;

import com.alibaba.fastjson.JSON;
import com.bsh.erp.base.BaseAction;
import com.bsh.erp.entity.BusinessBill;
import com.bsh.erp.tools.HqlHelper;
import com.bsh.erp.tools.PageBean;

/**
 * 业务单
 * 业务单模块
 * @author guo
 */
public class BusinessBillAction extends BaseAction<BusinessBill>{

	private static final long serialVersionUID = 1L;
	/**
	 * 新增业务单
	 */
	public void addBusinessBill(){
		try{
			businessBillService.save(getModel());
			outJson("成功！");
		}catch (Exception e) {
			outJson("失败！");
		}
	}
	
	/**
	 * 修改业务单
	 */
	public void updateBusinessBill(){
		try{
			businessBillService.update(getModel());
			outJson("成功！");
		}catch (Exception e) {
			outJson("失败!");
		}
	}
	
	/**
	 * 获取全部业务单
	 * 分页 10行
	 * pageNum 页码
	 * @return JSON数据
	 */
	public void findAllBusinessBill(){
		HqlHelper hqlHelper = new HqlHelper(BusinessBill.class, "businessBill");
		PageBean pageBean = businessBillService.getPageBean(pageNum, 10, hqlHelper);
		outJson(JSON.toJSONString(pageBean));
	}
	
	
	/**
	 * 作废 反作废 业务单
	 * enable 作废 反作废 
	 * id  执行数据的id
	 * @author guo
	 * @return Y N
	 */
	/*public void toEnableBusinessBill(){
		if(businessBillService.cancelEntity(getModel().getId(),getModel().getEnabled())){
			outJson("成功！");
		}else{
			outJson("失败！");
		}
	}*/
	
	/**
	 * 获取为作废业务单
	 * enable  Y N 作废 反作废
	 * pageNum  页码
	 * @author guo
	 * @return JSON
	 */
	/*public void UnEnableBusinessBill(){
		HqlHelper hqlHelper = new HqlHelper(BusinessBill.class, "businessBill").addWhereCondition("enable = ?", getModel().getEnabled());
		PageBean pageBean = businessBillService.getPageBean(pageNum, 10, hqlHelper);
		outJson(JSON.toJSONString(pageBean));
	}*/
}
